package com.wsz.eduservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wsz.eduservice.pojo.Comment;
import com.wsz.eduservice.service.CommentService;
import com.wsz.eduservice.mapper.CommentMapper;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author wangs
* @description 针对表【edu_comment(评论)】的数据库操作Service实现
* @createDate 2022-10-04 19:46:43
*/
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment>
    implements CommentService{

    @Override
    public Map<String, Object> getCommentPage(Page<Comment> pageParam, String courseId) {
        QueryWrapper<Comment> queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("course_id",courseId);


        baseMapper.selectPage(pageParam,queryWrapper);

        List<Comment> commentList = pageParam.getRecords();

        Map<String, Object> map = new HashMap<>();
        map.put("items", commentList);
        map.put("current", pageParam.getCurrent());
        map.put("pages", pageParam.getPages());
        map.put("size", pageParam.getSize());
        map.put("total", pageParam.getTotal());
        map.put("hasNext", pageParam.hasNext());
        map.put("hasPrevious", pageParam.hasPrevious());
        return map;
    }
}




